package rest.jbpm.wrappers.lists;

import java.util.*;
import javax.xml.bind.annotation.*;
import rest.jbpm.wrappers.Variable;
import rest.jbpm.wrappers.refs.VariableRef;


@XmlRootElement
@XmlAccessorType(XmlAccessType.PROPERTY)
@XmlType(name = "variables", propOrder = {
    "variables","variablesUnwrapped"})
public class VariableList {
	
	private List<VariableRef> _refs;
    private List<Variable> _vars;
	
	protected VariableList() {
		
	}
	
    /*
	public VariableList(Collection<String> names, String taskId, String baseUri) {
		_refs = new ArrayList<VariableRef>();
		
		for(String name : names)
			_refs.add(new VariableRef(taskId,name,baseUri));
	}
     * 
     */
    
    public VariableList(Map<String,Object> variables, String taskId, String baseUri) {
		_vars = new ArrayList<Variable>();
		
		for(String name : variables.keySet())
            _vars.add(new Variable(name, variables.get(name) == null ? 
                    null : variables.get(name).toString()));
	}
	
	@XmlElement(name="variable" , required=false)
	public List<VariableRef> getVariables() {
		return _refs;
	}
    
    @XmlElement(name="variable" , required=false)
	public List<Variable> getVariablesUnwrapped() {
		return _vars;
	}

}
